package com.kingwang.training.designpattern.state;

import com.kingwang.training.designpattern.state.bo.Lift;
import com.kingwang.training.designpattern.state.bo.OpenState;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class StateApplication implements ApplicationRunner {

    public static void main(String[] args) {
        SpringApplication.run(StateApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        Lift lift = new Lift(new OpenState());

        lift.closeDoor();
        lift.run();
        lift.stop();

        lift.closeDoor();
        lift.openDoor();
        lift.stop();
        lift.run();
    }
}
